<template>
  <div class="app-container">
    <div class="table-page-search-wrapper">
      <el-form :inline="true" label-width="100px">
        <el-row :gutter="18">
          <el-col :md="8" :sm="24">
            <el-form-item label="创建时间">
              <el-date-picker
                v-model="queryParam.createTime"
                clearable
                type="date"
                value-format="yyyy-MM-dd"
                @change="onSearch"
              />
            </el-form-item>
          </el-col>
          <el-col :md="8" :sm="24">
            <el-form-item label="任务单id">
              <el-input-number
                v-model="queryParam.taskId"
                controls-position="right"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
          </el-col>
          <template v-if="advanced">
            <el-col :md="8" :sm="24">
              <el-form-item label="工艺编号">
                <el-input v-model="queryParam.techNum" placeholder="" clearable @keyup.enter.native="onSearch" @clear="onSearch" />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="工艺名称">
                <el-input v-model="queryParam.techName" placeholder="" clearable @keyup.enter.native="onSearch" @clear="onSearch" />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="工艺数量">
                <el-input v-model="queryParam.techQuantity" placeholder="" clearable @keyup.enter.native="onSearch" @clear="onSearch" />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="工艺开始时间">
                <el-date-picker
                  v-model="queryParam.techStartTime"
                  clearable
                  type="date"
                  value-format="yyyy-MM-dd"
                  @change="onSearch"
                />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="工艺结束时间">
                <el-date-picker
                  v-model="queryParam.techEndTime"
                  clearable
                  type="date"
                  value-format="yyyy-MM-dd"
                  @change="onSearch"
                />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="加工设备">
                <el-input v-model="queryParam.equipment" placeholder="" clearable @keyup.enter.native="onSearch" @clear="onSearch" />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="排序">
                <el-input-number
                  v-model="queryParam.sort"
                  controls-position="right"
                  @keyup.enter.native="onSearch"
                />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="状态 0未完成1已完成2进行中">
                <el-input-number
                  v-model="queryParam.state"
                  controls-position="right"
                  @keyup.enter.native="onSearch"
                />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="生产任务编号">
                <el-input v-model="queryParam.productTaskNum" placeholder="" clearable @keyup.enter.native="onSearch" @clear="onSearch" />
              </el-form-item>
            </el-col>
            <el-col :md="8" :sm="24">
              <el-form-item label="操作工">
                <el-input-number
                  v-model="queryParam.userId"
                  controls-position="right"
                  @keyup.enter.native="onSearch"
                />
              </el-form-item>
            </el-col>
          </template>
          <el-col :md="!advanced && 8 || 24" :sm="24">
            <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
              <el-button v-waves type="primary" icon="el-icon-search" @click="onSearch">
                查询
              </el-button>
              <el-button type="info" icon="el-icon-refresh" @click="reset">
                重置
              </el-button>
              <el-link type="primary" :underline="false" @click="toggleAdvanced">
                {{ advanced ? '收起' : '展开' }}
                <i :class="advanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'" />
              </el-link>
            </span>
          </el-col>
        </el-row>
      </el-form>
    </div>

    <div class="table-operator">
      <el-button v-permission="['create']" type="primary" icon="el-icon-plus" @click="$refs.form.open(undefined)">
        新建
      </el-button>
    </div>

    <el-table
      v-loading="loadingData"
      :data="list"
      element-loading-text="Loading"
      fit
      highlight-current-row
      row-key="id"
      @sort-change="appendSorterParam"
    >
      <el-table-column align="center" label="创建时间">
        <template slot-scope="scope">
          <span>{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="任务单id">
        <template slot-scope="scope">
          <span>
            {{ scope.row.taskId }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="工艺编号">
        <template slot-scope="scope">
          <span>
            {{ scope.row.techNum }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="工艺名称">
        <template slot-scope="scope">
          <span>
            {{ scope.row.techName }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="工艺数量">
        <template slot-scope="scope">
          <span>
            {{ scope.row.techQuantity }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="工艺开始时间">
        <template slot-scope="scope">
          <span>{{ scope.row.techStartTime }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="工艺结束时间">
        <template slot-scope="scope">
          <span>{{ scope.row.techEndTime }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="加工设备">
        <template slot-scope="scope">
          <span>
            {{ scope.row.equipment }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="排序">
        <template slot-scope="scope">
          <span>
            {{ scope.row.sort }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="状态 0未完成1已完成2进行中">
        <template slot-scope="scope">
          <span>
            {{ scope.row.state }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="生产任务编号">
        <template slot-scope="scope">
          <span>
            {{ scope.row.productTaskNum }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作工">
        <template slot-scope="scope">
          <span>
            {{ scope.row.userId }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
        <template slot-scope="{row}">
          <el-button
            v-permission="['detail']"
            type="text"
            @click="$refs.detail.open(row.id)"
          >
            详情
          </el-button>
          <span
            v-permission="['detail']"
            v-permission-again="['update', 'delete']"
          >
            <el-divider
              direction="vertical"
            />
          </span>
          <el-dropdown
            v-permission="['update', 'delete']"
            @command="command => menuCommand(command, row)"
          >
            <el-button type="text">
              更多<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                v-permission="['update']"
                command="update"
                icon="el-icon-edit"
              >
                编辑
              </el-dropdown-item>
              <el-dropdown-item
                v-permission="['delete']"
                command="delete"
                icon="el-icon-delete"
              >
                删除
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="pagination.total>0"
      :total="pagination.total"
      :page.sync="pagination.current"
      :limit.sync="pagination.pageSize"
      :style="{textAlign: 'right'}"
      @pagination="handlePaginationChanged"
    />

    <diboot-form ref="form" @complete="getList" />
    <diboot-detail ref="detail" />
  </div>
</template>

<script>
import list from '@/components/diboot/mixins/list'
import dibootForm from './form'
import dibootDetail from './detail'
import waves from '@/directive/waves'
export default {
  name: 'TechniqueList',
  directives: { waves },
  components: {
    dibootForm,
    dibootDetail
  },
  mixins: [list],
  data() {
    return {
      baseApi: '/technique',
      getListFromMixin: true

    }
  }
}
</script>
<style lang="scss" scoped>
</style>
